package site.marqstree.kotlin.library.good.ui.fragment.category.list.presenter

import site.marqstree.kotlin.library.base.data.net.observer.RxObserver
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2List
import site.marqstree.kotlin.library.base.presenter.view.BasePresenter
import site.marqstree.kotlin.library.good.ui.fragment.category.list.view.CategoryListView
import site.marqstree.kotlin.library.good.ui.fragment.category.list.bean.CategoryBean
import site.marqstree.kotlin.provider.common.ProviderConstant
import javax.inject.Inject


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.library.good.ui.fragment.category
 * 文件名: CategoryPresenter
 * 创建者: marqstree
 * 创建时间: 2020/3/6 15:03
 * 描述: TODO
 */
class CategoryListPresenter @Inject constructor():BasePresenter<CategoryListView>(){

    fun getCategoryList(){
        RxRequest.builder()
            .setUrl(ProviderConstant.CATEGORY_LIST_URL)
            .get()
            .json2List(CategoryBean::class.java)
            .subscribe(object :RxObserver<List<CategoryBean>>(){
                override fun onNext(data: List<CategoryBean>) {
                    mView.onCategoryListResult(data)
                }
            })
    }
}